import { connect } from "react-redux";
import { actions } from "../redux/actions";

export const decorater = function(handler = () => {}) {
  return function(thisComponent) {
    const newPage = class extends thisComponent {
      componentWillMount() {
        super.componentWillMount();
        console.log("decorater componentWillMount");
      }
    };
    const mapStateToProps = (state, props) => handler(state);

    const mapDispatchToProps = actions;

    return connect(
      mapStateToProps,
      mapDispatchToProps
    )(newPage);
  };
};
